#pragma once

#include "DataType.h"

#include "Operation.h"
#include "Property.h"

namespace uml {

DataType::DataType(const QString& umlType)
    : Classifier(umlType) {}

void DataType::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    Classifier::fromJson(json, errorList);
    JsonSerializable::fromJsonArray(ownedAttributes_, "ownedAttributes", json, errorList);
    JsonSerializable::fromJsonArray(ownedOperations_, "ownedOperations", json, errorList);
}

void DataType::toJson(QJsonObject& json) {
    Classifier::toJson(json);
    JsonSerializable::toJsonArray(ownedAttributes_, "ownedAttributes", json);
    JsonSerializable::toJsonArray(ownedOperations_, "ownedOperations", json);
}

/// <summary>
/// ownedAttributes getter
/// The attributes owned by the DataType.
/// </summary>
vector<shared_ptr<Property>>& DataType::ownedAttributes() {
    return ownedAttributes_;
}

/// <summary>
/// ownedOperations getter
/// The Operations owned by the DataType.
/// </summary>
vector<shared_ptr<Operation>>& DataType::ownedOperations() {
    return ownedOperations_;
}

} // namespace uml
